/*
 * Copyright (c) 2011 Sapienza University of Rome.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * - Redistributions of source code must retain the above copyright
 *   notice, this list of conditions and the following disclaimer.
 * - Redistributions in binary form must reproduce the above copyright
 *   notice, this list of conditions and the following disclaimer in the
 *   documentation and/or other materials provided with the
 *   distribution.
 * - Neither the name of the Sapienza University of Rome nor the names of
 *   its contributors may be used to endorse or promote products derived
 *   from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL SAPIENZA
 * UNIVERSITY OF ROME OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
 * OF THE POSSIBILITY OF SUCH DAMAGE.
 */
/**
 * @author Ugo Colesanti <colesanti@dis.uniroma1.it>
 * @version 1.01 (September 28, 2011)
 *
 */
enum{
	SENSOR_COUNT = 6,
	AM_PACKET_RECEIVED = 0x9a,
	AM_FLASHLOGMSG = 0x06,

	SAMPLING_OFFSET = 286720UL,//53248UL,//286720UL, // 5min - 20seconds //53248UL, // 307200
	SAFETY_INTERVAL = 512,

	FLUSH = 0x01,
	SERIAL_FLUSH = 0x02,
};

typedef nx_struct stats{				// Tot -->  7 B
	nx_uint16_t from ;					// 			2 B
	nx_uint8_t thl ;					// 			1 B
	nx_uint32_t rxTimestamp ;			// 			4 B
} stats_t ;

typedef nx_struct stats_schedule{		// Tot -->  7 B
	nx_uint8_t skip ;					// 			1 B
	nx_uint16_t gt ;					//			2 B
	nx_uint16_t ri ;					//			2 B
	nx_uint16_t dci ;					// 			2 B
} stats_schedule_t ;

typedef nx_struct sensor_data{
	nx_uint16_t data ;
	nx_uint16_t temp ;
}sensor_data_t;

typedef nx_struct app_data{				// Tot --> 32 B
	nx_uint16_t seqno ;					//			2 B
	nx_uint16_t voltage ;				//			2 B
	nx_uint32_t sensor_timer ;			//			4 B
	nx_uint32_t timestamp ;				//			4 B
	sensor_data_t sensor[SENSOR_COUNT] ;// 6x2x2 = 24 B
} app_data_t ;

// this structure should be integrated in app_data
typedef nx_struct serial_sensor_data{
	nx_uint32_t sensor_timer ;
	sensor_data_t sensor[SENSOR_COUNT] ;
}serial_sensor_data_t ;

typedef nx_struct packet_received{		// Tot -->  46 B
	app_data_t app_data ;				//			32 B
	stats_t stats ;						//			 7 B
	stats_schedule_t stats_schedule ;	//			 7 B
}packet_received_t ;

typedef nx_struct flashLogMsg{
	nx_uint8_t type ;
	nx_uint16_t offset ;
}flashLogMsg_t ;
